﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"] - 制章管理系统</title>
    <style>
        table.fixed {
           
            table-layout: fixed; /* 只有定义了表格的布局算法为fixed，下面td的定义才能起作用。 */
        }

        td.hide {
            
            word-break: keep-all; /* 不换行 */
            white-space: nowrap; /* 不换行 */
            overflow: hidden; /* 内容超出宽度时隐藏超出部分的内容 */
            text-overflow: ellipsis; /* 当对象内文本溢出时显示省略标记(...) ；需与overflow:hidden;一起使用*/
        } 
    </style>
    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
    <link rel="stylesheet" href="~/css/site.css" />
    <link href="~/Content/layui/css/layui.css" rel="stylesheet" />
</head>
<body>
    @*通过viewcompent请求*@
    @*@await Component.InvokeAsync("Navigation");*@
    @*通过ajax请求*@
    @* <nav class="navbar navbar-inverse navbar-fixed-top"> *@
    <nav class="navbar navbar-inverse">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a style="float: left;height: 50px;line-height:50px;">
                    @*<img src="~/images/logo.png" style="height:50px;" />*@

                </a>
            </div>
                <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                    <ul class="nav navbar-nav" id="side-menu"></ul>
                </div>
            
        </div>
    </nav>

    <partial name="_CookieConsentPartial" />

    <div class="container body-content">
        @RenderBody()
        <hr />
        <footer>
            <p>&copy; 2018 - 制章管理系统</p>
        </footer>
    </div>

    <script src="~/lib/jquery/dist/jquery.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
    <script src="~/Content/layui/layui.js"></script>
    <script src="~/js/site.js" asp-append-version="true"></script>

    <script>
        $(function () {
            layui.use(['laypage', 'layer'], function () {
                var laypage = layui.laypage
                    , layer = layui.layer;
            });
            //初始化菜单项
            $.ajax({
                url: "/Navigation/Index",
                type: 'Get',
                success: function (result) {
                    console.log(result);
                    if (result != null && result.state == '200') {
                        var menuItems = result.data;
						console.log(menuItems);
                        var _html = '';
                        $.each(menuItems, function (i) {
                            var menuItem = menuItems[i];
                            _html += '<li class="dropdown ">';
                            _html += '<a href="#" class="dropdown-toggle " data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">' + menuItem.menuString + ' <span class="caret"></span></a>';
                            var childNodes = menuItem.ChildNodes;//二级
                            _html += '<ul class="dropdown-menu">';
                            $.each(menuItem.childNodes, function (i) {
                                var childNode = menuItem.childNodes[i];
                                _html += '<li>';
                                _html += '<a href="' + childNode.menuPath + '" >' + childNode.menuString + '</a>';
                                _html += '</li>';
                            });
                            _html += '</ul>';
                            _html += '</li>';
                        });
                        _html += '<li class="dropdown ">';
                        _html += '<a href="/Login/LogOut" id="LogOut" class="dropdown-toggle LogOut" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">退出系统 <span class="caret"></span></a>';
                        _html += '</li>';
                        $(_html).appendTo("#side-menu");
                    } else {
                        var _html = '';
                        // _html += '<li class="dropdown ">';
                        // _html += '<a href="#" class="dropdown-toggle " data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">登录系统 <span class="caret"></span></a>';
                        // _html += '<ul class="dropdown-menu">';
                        // _html += '<li><a href="/Login/Login">管理员</a></li>';
                        // _html += '<li><a href="/Login/SignMakerLogin">制章人</a></li>';
                        // _html += '</ul>';
                        // _html += '</li>';
                        $(_html).appendTo("#side-menu");
                    }
                }
            });
            //登录系统
            //$("#login").click(function () {
            //    var params = $("#myform").serialize();
            //    console.log(params);
            //    $.post("/Login/Login", params, function (e) {
            //        console.log(e);
            //        if (e.state == 200) {

            //            location.href = e.data.url;
            //        }
            //    })
            //})

            //退出系统
            $('#side-menu').on('click', "#LogOut", function () {
                layer.open({
                    type: 1
                    , offset: 'auto'
                    , id: 'confirm'
                    , move: false
                    , title: '确认窗口'
                    , scrollbar: true
                    , content: '<div style="padding: 20px 40px;"> 确认退出系统吗？</div>'
                    , btn: ['确认', '取消']
                    , scrollbar: false
                    , resize: false
                    , moveType: 1 //拖拽模式，0或者1
                    , area: ['200px', '160px']
                    , btnAlign: 'c' //按钮居中
                    , shade: 0 //不显示遮罩
                    , yes: function () { 
                        $.ajax({
                            url: "/Login/LogOut",
                            type: 'Get',
                            success: function (data) {
                                if (data != null && data.state == '200') {
                                    window.sessionStorage.removeItem("UserType");
                                    window.sessionStorage.removeItem("makerCertID");
                                    if (data.logintype == '1') {
                                        window.location.href = '/Login/Login';
                                    } else {
                                        window.location.href = '/Login/Login';
                                    }
                                    // $("#login_btn").show();
                                    // var timer = setInterval(function () { $.ajax(getting) }, 1000);
                                }
                            }
                        });
                        layer.closeAll();
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        layer.close();
                        //return false 开启该代码可禁止点击该按钮关闭
                    }
                });
            })
        })
    </script>
    @RenderSection("Scripts", required: false)
</body>
</html>
